package com.jitu.bigscreen.test;

import com.jitu.bigscreen.component.LedControlInf;
import com.jitu.bigscreen.model.Date;
import com.jitu.bigscreen.model.*;
import org.codehaus.jackson.JsonGenerationException;
import org.codehaus.jackson.map.JsonMappingException;
import org.codehaus.jackson.map.ObjectMapper;

import java.io.IOException;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;

public class test {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		int retValue = -1;
		String ip = "192.168.0.196\0";
        byte[] iptobytes = ip.getBytes();

		try {
//			System.out.println(System.getProperty("java.class.path"));
            //System.out.println(System.getProperty("user.dir"));
//			 retValue = LedControlInf.INSTANCE.RtfConvertBmp3_1("F:\\linux\\temp.rtf",0,256, 256,0, 1, 256, 256, 0);
//			 retValue = LedControlInf.INSTANCE.AdjustTime(ip);

			 //LedControlInf.INSTANCE.LV_InitDllTest();
			//1、初始化
			 LedControlInf.INSTANCE.LV_InitDllEx(1);

//			 //2、执行操作指令
//			 //关屏操作
//			 btCloseScreen_Click(iptobytes);
//			 //开屏操作
//			 btOpenScreen_Click(iptobytes);
			 //发送节目操作
			 btMulProgram_Click(iptobytes);
//			 btMulProgramByPeriod_Click(iptobytes,10);
//			 btMulProgramByInsert_Click(iptobytes);
			 //获取设备信息操作
			 btGetDeviceInfo_Click(iptobytes);

			 //压力测试操作
//			 processConcurrentTest(iptobytes);
		} catch (Exception e) {
			// TODO: handle exception
		  System.out.println(e);
		}

	}

	//压力测试节目发送
	public static void processConcurrentTest( byte[] iptobytes) throws ParseException
	{
		while(true){
			 try {

				 btMulProgramByPeriod_Click(iptobytes,10);

				 Thread.sleep(2*60*1000);

			 }catch (InterruptedException e) {
		            e.printStackTrace();
		      }
		}
	}

	 //获取设备信息
	 private static void btGetDeviceInfo_Click(byte[] pIp)
    {
		int retValue = 0;
		byte[] pVersionInfo = new byte[2048];
		try {
			retValue = LedControlInf.INSTANCE.LV_GetDeviceVersion(pIp, pVersionInfo,pVersionInfo.length);
			System.out.println(new String(new String(pVersionInfo).getBytes("ISO8859_1"),"UTF-8"));
	        System.out.println(retValue == 0 ? "获取设备信息成功" : "获取设备信息失败");
		} catch (Exception e) {
			// TODO: handle exception
		}
    }

	 //关屏指令
	 private static void btCloseScreen_Click(byte[] pIp)
     {
		int retValue = 0;
		try {
			retValue = LedControlInf.INSTANCE.LV_SwitchLed(pIp, 0);
	        System.out.println(retValue == 0 ? "关屏成功" : "关屏失败");
		} catch (Exception e) {
			// TODO: handle exception
		}
     }

	 //开屏指令
	 private static void btOpenScreen_Click(byte[] pIp )
     {
			int retValue = 0;
			try {
				retValue = LedControlInf.INSTANCE.LV_SwitchLed(pIp,1);
		        System.out.println(retValue == 0 ? "开屏成功" : "开屏失败");
			} catch (Exception e) {
				// TODO: handle exception
			}
     }

	 //同步时间指令
	 private static void btSynchronizationTime_Click(byte[] pIp )
     {
			int retValue = 0;
			try {
				retValue = LedControlInf.INSTANCE.LV_SynchronizationTime (pIp);
		        System.out.println(retValue == 0 ? "同步时间成功" : "同步时间失败");
			} catch (Exception e) {
				// TODO: handle exception
			}
     }

	 //多节目多页面-发送轮播节目
	 private static void btMulProgram_Click(byte[] iptobytes) throws ParseException
     {

	   String screenName1 ="test1";
	   String pProgramId = "13";
	   String pProgramName = "13";

	   byte[] pProgramIdToBytes = (pProgramId + "\0") .getBytes();
	   byte[] pProgramNameToBytes = (pProgramName + "\0").getBytes();
	   byte[] screenNameToBytes = (screenName1 + "\0") .getBytes();

	   //String rootPath = /*System.getProperty("user.dir")+*/"../resources/";
	   String rootPath = LedControlInf.osTypeFlag.equals("windows") ? System.getProperty("user.dir")+"\\resources\\" : "../resources/";
	    byte[] errByt =new byte[2048];
	   try {

		 int retValue = 0;
         retValue = LedControlInf.INSTANCE.LV_ClearProgram(screenNameToBytes);
         System.out.println("LV_ClearProgram = " + retValue);

         Random rd = new Random();
         int pageId = rd.nextInt(100);
         //直行
         String src1 = rootPath + "88.jpg";

         //*****************第一步 添加节目页面***********************************************************************
         Page page = new Page();
         page.setPageId(pageId);
         page.setResolution("1920X1080");
         page.setBgColor("#000000");
         page.setBgImg("");
         page.setEqType("Q5");
         page.setPageTime(10);
         UUID uuid = UUID.randomUUID();
         page.setGuid(uuid.toString());

          //对象转为Json
         ObjectMapper mapper = new ObjectMapper();
         String pPageJson = mapper.writeValueAsString(page);
         System.out.println(pPageJson);

         byte[] pageJsontoBytes = (pPageJson+ "\0").getBytes();
         int resurt1 = LedControlInf.INSTANCE.LV_AddPageToProgram(screenNameToBytes, pProgramIdToBytes, pageJsontoBytes);

//         byte[] errByt = new byte[2048];
//         retValue = LedControlInf.INSTANCE.LV_GetLastErrInfo(errByt, errByt.length);
//
//         System.out.println(new String(new String(errByt).getBytes("ISO8859_1"),"UTF-8"));
         System.out.println(resurt1 == 0 ? "添加节目页面成功" : "添加节目页面失败");

         //*****************第二步 在节目页面上添加对应的显示区域*********************************************************

         //图片区域
         PictureArea a = new PictureArea();
         a.setId(1);
         a.setType(1);
         a.setBorderEffect(0);
         a.setBorderSW(0);
         a.setBorderSpeed(0);
         a.setBorderType(0);
         a.setLeft(0);
         a.setTop(0);
         a.setWidth(128);
         a.setHeight(128);
         a.setPauseTime(5);
         a.setRotation(0);
         a.setSiderType(6);
         List<SrcGroup> lsg = new ArrayList<SrcGroup>();
         a.setSrcGroup(lsg);

         SrcGroup s = new SrcGroup();
         s.setId(1);
         s.setSrc(src1);
         a.getSrcGroup().add(s);

         SrcGroup s1 = new SrcGroup();
         s1.setId(2);
         src1 = rootPath + "83.jpg";
         s1.setSrc(src1);
         a.getSrcGroup().add(s1);
         a.setzIndex(0);

         //对象转为Json
         String ajson = mapper.writeValueAsString(a);

         System.out.println(ajson);

         byte[] ajsontobytes = (ajson+ "\0").getBytes();
//         int resurt2 = LedControlInf.INSTANCE.LV_AddArea(iptobytes, pid, ajsontobytes);
         int resurt2 = LedControlInf.INSTANCE.LV_AddArea(screenNameToBytes,pProgramIdToBytes, pageId, ajsontobytes);
//         retValue = LedControlInf.INSTANCE.LV_GetLastErrInfo(errByt, errByt.length);
//         System.out.println(new String(new String(errByt).getBytes("ISO8859_1"),"UTF-8"));
         System.out.println(resurt2 == 0 ? "添加图片区域成功" : "添加图片区域失败");


       //视频区域
         VideoArea videoArea = new VideoArea();
         videoArea.setId(3);
         videoArea.setType(0);
         videoArea.setBorderEffect(1);
         videoArea.setBorderSW(1);
         videoArea.setBorderSpeed(1);
         videoArea.setBorderType(9);
         videoArea.setLeft(0);
         videoArea.setTop(256);
         videoArea.setWidth(288);
         videoArea.setHeight(96);
         videoArea.setPauseTime(5);
         videoArea.setRotation(0);
         videoArea.setSiderType(6);
         List<SrcGroup> lsgVideoArea = new ArrayList<SrcGroup>();
         videoArea.setSrcGroup(lsgVideoArea);

         src1 = rootPath + "21.mp4";
         SrcGroup sVideoArea = new SrcGroup();
         sVideoArea.setId(1);
         sVideoArea.setSrc(src1);
         videoArea.getSrcGroup().add(sVideoArea);

         SrcGroup sVideoArea1 = new SrcGroup();
         sVideoArea1.setId(2);
         src1 = rootPath + "23.mp4";
         sVideoArea1.setSrc(src1);
         videoArea.getSrcGroup().add(sVideoArea1);
         videoArea.setzIndex(0);

         //对象转为Json
         String vjson = mapper.writeValueAsString(videoArea);

         System.out.println(vjson);

         byte[] vjsontobytes = (vjson+ "\0").getBytes();
//         int resurt3 = LedControlInf.INSTANCE.LV_AddArea(iptobytes, pid, vjsontobytes);
         int resurt3 = LedControlInf.INSTANCE.LV_AddArea(screenNameToBytes,pProgramIdToBytes, pageId, vjsontobytes);
//         retValue = LedControlInf.INSTANCE.LV_GetLastErrInfo(errByt, errByt.length);
//         System.out.println(new String(new String(errByt).getBytes("ISO8859_1"),"UTF-8"));
         System.out.println(resurt3 == 0 ? "添加视频区域成功" : "添加视频区域失败");


         //文本区域
         TextArea textArea = new TextArea();
         //id
         textArea.setId(2);
     	//type Int 区域素材类型，字幕对应的类型为:2
         textArea.setType(2);
     	//borderSW Int 区域边框开关 1:开 0:关
         textArea.setBorderSW(0);
      	//borderEffect Int 区域边框特效 0:静止 1:旋转 2:闪烁
         textArea.setBorderEffect(0);
     	//颜色特效 0:无 1:水平渐变 2:垂直渐变 3:斜角渐变
         textArea.setColorEffect(0);
     	//borderSpeed int 区域边框速度 0~4
         textArea.setBorderSpeed(0);
     	//borderType Int 区域边框类型 0~9 详见附录
         textArea.setBorderType(0);
     	//left Int 区域 x 坐标点
         textArea.setLeft(256);
     	//top Int 区域 y 坐标点
         textArea.setTop(0);
     	//width Int 区域宽度
         textArea.setWidth(256);
     	//height Int 区域高度
         textArea.setHeight(64);
     	//background String 背景颜色,如:”#000000”,16 进制的 RRGGBB
         textArea.setBackground("#000000");
     	//fontColor String 文字颜色, 如:”#ffffff”,16 进制的 RRGGBB
         textArea.setFontColor("#00ff00");
     	//fontFamily String 文字字体,如”宋体”
          textArea.setFontFamily(LedControlInf.osTypeFlag.equals("windows") ?"宋体":rootPath + "font/simsun.ttc");
     	//fontSize Int 字体大小 12~128 ,单位 px
         textArea.setFontSize(48);
     	//italic Int 是否斜体 1:是 0:否
         textArea.setItalic(0);
     	// bold Int 是否粗体 1:是 0:否
         textArea.setBold(1);
     	//textLine Int 文字线 0:无 1:下划线 2:删除线
         textArea.setTextLine(0);
     	//lineHeight Int 行间距,多行时有效
         textArea.setLineHeight(5);
     	//pauseTime Int 停留时间,当字幕为向左向右平移时的停留时间,连续移 动无效 0~255
         textArea.setPauseTime(5);
     	//scrollSpeed Int 字幕滚动速度 0~14
         textArea.setScrollSpeed(2);
     	//siderType Int 滚动方式 0:静止 1:向左移动 2:向左连续移动 3:向右移动 4:向右连续移动
         textArea.setSiderType(2);
     	//textAlign Int 对齐方式 0:左,1:中间 2:右
         textArea.setTextAlign(0);

         textArea.setTextTop(0);

         String strTextInfo = "AAAA灵信视觉二次开发动态库文本发送";
//         String base64Sign = base64.encodeToString(strTextInfo.getBytes("UTF-8"));
         textArea.setText(strTextInfo);
     	//textShow Int 字幕显示方式 1:单行 0:多行
         textArea.setTextShow(1);
     	//zIndex int 层级
     	textArea.setzIndex(0);

        //对象转为Json
        String tjson = mapper.writeValueAsString(textArea);

        System.out.println(tjson);

        byte[] tjsontobytes = (tjson+ "\0").getBytes();
//        int resurt4 = LedControlInf.INSTANCE.LV_AddArea(iptobytes, pid, tjsontobytes);
        int resurt4 = LedControlInf.INSTANCE.LV_AddArea(screenNameToBytes,pProgramIdToBytes, pageId, tjsontobytes);
//        retValue = LedControlInf.INSTANCE.LV_GetLastErrInfo(errByt, errByt.length);
//        System.out.println(new String(new String(errByt).getBytes("ISO8859_1"),"UTF-8"));
        System.out.println(resurt4 == 0 ? "添加文本区域成功" : "添加文本区域失败");

        //*****************第三步 发送节目内容*********************************************************

     	//节目发送
//         retValue = LedControlInf.INSTANCE.LV_SendProgramToDevice(iptobytes);

         retValue = LedControlInf.INSTANCE.LV_SendProgramToDevice(screenNameToBytes,iptobytes,pProgramIdToBytes,pProgramNameToBytes,new byte[0]);
//         if(retValue != 0){
//            retValue = LedControlInf.INSTANCE.LV_GetLastErrInfo(errByt, errByt.length);
//            System.out.println(new String(new String(errByt).getBytes("ISO8859_1"),"UTF-8"));
//         }
         System.out.println(retValue == 0 ? "节目内容发送成功" : "节目内容发送失败");

         //*****************第四步 发送节目计划,执行播放节目指令 *********************************************************
         String pDefResVideoFile ="\0";

//         MulProgram mulProgram = new MulProgram();


         List<ProgramPlan> lsProgram = new ArrayList<ProgramPlan>();

         ProgramPlan programPlan = new ProgramPlan();
         programPlan.setCreateDate(String.valueOf(new java.util.Date().getTime()));
         programPlan.setProgramId(pProgramId);
         programPlan.setProgramName(pProgramName);
         programPlan.setProgramType(1);//1标识为轮播节目
         programPlan.setUpdateDate(String.valueOf(new java.util.Date().getTime()));

         List<Date> lsDate = new ArrayList<Date>();
         SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
         Date date = new Date();
         date.setDateStart(formatter.parse("2020-03-30").getTime());
         date.setDateEnd(formatter.parse("2020-04-30").getTime());
         lsDate.add(date);
         programPlan.setDate(lsDate);

         List<Time> lsTime = new ArrayList<Time>();
         Time time = new Time();
         time.setTimeStart("07:59:59");
         time.setTimeEnd("21:59:59");
         lsTime.add(time);
         programPlan.setTime(lsTime);

         programPlan.setIsDefault(1);
         List lsPlanWeekDay = new ArrayList();
         for(int i=0;i<7;i++){
        	 lsPlanWeekDay.add(1);
         }
         programPlan.setPlanWeekDay(lsPlanWeekDay);
         lsProgram.add(programPlan);

//         mulProgram.setProgram(lsProgram);

         //对象转为Json
         String pPlanJsonData = mapper.writeValueAsString(lsProgram);
         System.out.println(pPlanJsonData);
         byte[] pPlanDatatobytes = (pPlanJsonData+ "\0").getBytes();
         retValue = LedControlInf.INSTANCE.LV_SendProgramPlan(iptobytes, pPlanDatatobytes, pDefResVideoFile.getBytes());
         System.out.println(retValue == 0 ? "节目更新计划发送成功" : "节目更新发送失败");


         retValue = LedControlInf.INSTANCE.LV_ProgramSendProcessEnd();
         System.out.println(retValue == 0 ? "节目缓存清理成功" : "节目缓存清理失败");
		} catch (JsonGenerationException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (JsonMappingException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
     }
//	 private static void btMulProgram_Click(byte[] iptobytes) throws ParseException
//     {
//
//	   String screenName1 ="test1";
//	   String pProgramId = "13";
//	   String pProgramName = "13";
//
//	   byte[] pProgramIdToBytes = (pProgramId + "\0") .getBytes();
//	   byte[] pProgramNameToBytes = (pProgramName + "\0").getBytes();
//	   byte[] screenNameToBytes = (screenName1 + "\0") .getBytes();
//
//	   String rootPath = System.getProperty("user.dir")+"\\resources\\";
//
//	    byte[] errByt =new byte[2048];
//	   try {
//
//		 int retValue = 0;
//         retValue = LedControlInf.INSTANCE.LV_ClearProgram(screenNameToBytes);
//         System.out.println("LV_ClearProgram = " + retValue);
//
//         Random rd = new Random();
//         int pageId = rd.nextInt(100);
//         //直行
//         String src1 = rootPath + "88.jpg";
//
//         //*****************第一步 添加节目页面***********************************************************************
//         Page page = new Page();
//         page.setPageId(pageId);
//         page.setResolution("1920X1080");
//         page.setBgColor("#000000");
//         page.setBgImg("");
//         page.setEqType("Q5");
//         page.setPageTime(10);
//         UUID uuid = UUID.randomUUID();
//         page.setGuid(uuid.toString());
//
//          //对象转为Json
//         ObjectMapper mapper = new ObjectMapper();
//         String pPageJson = mapper.writeValueAsString(page);
//         System.out.println(pPageJson);
//
//         byte[] pageJsontoBytes = pPageJson.getBytes();
//         int resurt1 = LedControlInf.INSTANCE.LV_AddPageToProgram(screenNameToBytes, pProgramIdToBytes, pageJsontoBytes);
//
////         byte[] errByt = new byte[2048];
////         retValue = LedControlInf.INSTANCE.LV_GetLastErrInfo(errByt, errByt.length);
////
////         System.out.println(new String(new String(errByt).getBytes("ISO8859_1"),"UTF-8"));
//         System.out.println(resurt1 == 0 ? "添加节目页面成功" : "添加节目页面失败");
//
//         //*****************第二步 在节目页面上添加对应的显示区域*********************************************************
//
//         //图片区域
//         PictureArea a = new PictureArea();
//         a.setId(1);
//         a.setType(1);
//         a.setBorderEffect(0);
//         a.setBorderSW(0);
//         a.setBorderSpeed(0);
//         a.setBorderType(0);
//         a.setLeft(0);
//         a.setTop(0);
//         a.setWidth(128);
//         a.setHeight(128);
//         a.setPauseTime(5);
//         a.setRotation(0);
//         a.setSiderType(6);
//         List<SrcGroup> lsg = new ArrayList<SrcGroup>();
//         a.setSrcGroup(lsg);
//
//         SrcGroup s = new SrcGroup();
//         s.setId(1);
//         s.setSrc(src1);
//         a.getSrcGroup().add(s);
//
//         SrcGroup s1 = new SrcGroup();
//         s1.setId(2);
//         src1 = rootPath + "83.jpg";
//         s1.setSrc(src1);
//         a.getSrcGroup().add(s1);
//         a.setzIndex(0);
//
//         //对象转为Json
//         String ajson = mapper.writeValueAsString(a);
//
//         System.out.println(ajson);
//
//         byte[] ajsontobytes = ajson.getBytes();
////         int resurt2 = LedControlInf.INSTANCE.LV_AddArea(iptobytes, pid, ajsontobytes);
//         int resurt2 = LedControlInf.INSTANCE.LV_AddArea(screenNameToBytes,pProgramIdToBytes, pageId, ajsontobytes);
////         retValue = LedControlInf.INSTANCE.LV_GetLastErrInfo(errByt, errByt.length);
////         System.out.println(new String(new String(errByt).getBytes("ISO8859_1"),"UTF-8"));
//         System.out.println(resurt2 == 0 ? "添加图片区域成功" : "添加图片区域失败");
//
//
//       //视频区域
//         VideoArea videoArea = new VideoArea();
//         videoArea.setId(3);
//         videoArea.setType(0);
//         videoArea.setBorderEffect(1);
//         videoArea.setBorderSW(1);
//         videoArea.setBorderSpeed(1);
//         videoArea.setBorderType(9);
//         videoArea.setLeft(0);
//         videoArea.setTop(256);
//         videoArea.setWidth(288);
//         videoArea.setHeight(96);
//         videoArea.setPauseTime(5);
//         videoArea.setRotation(0);
//         videoArea.setSiderType(6);
//         List<SrcGroup> lsgVideoArea = new ArrayList<SrcGroup>();
//         videoArea.setSrcGroup(lsgVideoArea);
//
//         src1 = rootPath + "21.mp4";
//         SrcGroup sVideoArea = new SrcGroup();
//         sVideoArea.setId(1);
//         sVideoArea.setSrc(src1);
//         videoArea.getSrcGroup().add(sVideoArea);
//
//         SrcGroup sVideoArea1 = new SrcGroup();
//         sVideoArea1.setId(2);
//         src1 = rootPath + "23.mp4";
//         sVideoArea1.setSrc(src1);
//         videoArea.getSrcGroup().add(sVideoArea1);
//         videoArea.setzIndex(0);
//
//         //对象转为Json
//         String vjson = mapper.writeValueAsString(videoArea);
//
//         System.out.println(vjson);
//
//         byte[] vjsontobytes = vjson.getBytes();
////         int resurt3 = LedControlInf.INSTANCE.LV_AddArea(iptobytes, pid, vjsontobytes);
//         int resurt3 = LedControlInf.INSTANCE.LV_AddArea(screenNameToBytes,pProgramIdToBytes, pageId, vjsontobytes);
////         retValue = LedControlInf.INSTANCE.LV_GetLastErrInfo(errByt, errByt.length);
////         System.out.println(new String(new String(errByt).getBytes("ISO8859_1"),"UTF-8"));
//         System.out.println(resurt3 == 0 ? "添加视频区域成功" : "添加视频区域失败");
//
//
//         //文本区域
//         TextArea textArea = new TextArea();
//         //id
//         textArea.setId(2);
//     	//type Int 区域素材类型，字幕对应的类型为:2
//         textArea.setType(2);
//     	//borderSW Int 区域边框开关 1:开 0:关
//         textArea.setBorderSW(0);
//      	//borderEffect Int 区域边框特效 0:静止 1:旋转 2:闪烁
//         textArea.setBorderEffect(0);
//     	//颜色特效 0:无 1:水平渐变 2:垂直渐变 3:斜角渐变
//         textArea.setColorEffect(0);
//     	//borderSpeed int 区域边框速度 0~4
//         textArea.setBorderSpeed(0);
//     	//borderType Int 区域边框类型 0~9 详见附录
//         textArea.setBorderType(0);
//     	//left Int 区域 x 坐标点
//         textArea.setLeft(256);
//     	//top Int 区域 y 坐标点
//         textArea.setTop(0);
//     	//width Int 区域宽度
//         textArea.setWidth(256);
//     	//height Int 区域高度
//         textArea.setHeight(64);
//     	//background String 背景颜色,如:”#000000”,16 进制的 RRGGBB
//         textArea.setBackground("#000000");
//     	//fontColor String 文字颜色, 如:”#ffffff”,16 进制的 RRGGBB
//         textArea.setFontColor("#00ff00");
//     	//fontFamily String 文字字体,如”宋体”
//         textArea.setFontFamily("宋体");
//     	//fontSize Int 字体大小 12~128 ,单位 px
//         textArea.setFontSize(48);
//     	//italic Int 是否斜体 1:是 0:否
//         textArea.setItalic(0);
//     	// bold Int 是否粗体 1:是 0:否
//         textArea.setBold(1);
//     	//textLine Int 文字线 0:无 1:下划线 2:删除线
//         textArea.setTextLine(0);
//     	//lineHeight Int 行间距,多行时有效
//         textArea.setLineHeight(5);
//     	//pauseTime Int 停留时间,当字幕为向左向右平移时的停留时间,连续移 动无效 0~255
//         textArea.setPauseTime(5);
//     	//scrollSpeed Int 字幕滚动速度 0~14
//         textArea.setScrollSpeed(2);
//     	//siderType Int 滚动方式 0:静止 1:向左移动 2:向左连续移动 3:向右移动 4:向右连续移动
//         textArea.setSiderType(2);
//     	//textAlign Int 对齐方式 0:左,1:中间 2:右
//         textArea.setTextAlign(0);
//
//         textArea.setTextTop(0);
//
//         String strTextInfo = "AAAA灵信视觉二次开发动态库文本发送";
////         String base64Sign = base64.encodeToString(strTextInfo.getBytes("UTF-8"));
//         textArea.setText(strTextInfo);
//     	//textShow Int 字幕显示方式 1:单行 0:多行
//         textArea.setTextShow(1);
//     	//zIndex int 层级
//     	textArea.setzIndex(0);
//
//        //对象转为Json
//        String tjson = mapper.writeValueAsString(textArea);
//
//        System.out.println(tjson);
//
//        byte[] tjsontobytes = tjson.getBytes();
////        int resurt4 = LedControlInf.INSTANCE.LV_AddArea(iptobytes, pid, tjsontobytes);
//        int resurt4 = LedControlInf.INSTANCE.LV_AddArea(screenNameToBytes,pProgramIdToBytes, pageId, tjsontobytes);
////        retValue = LedControlInf.INSTANCE.LV_GetLastErrInfo(errByt, errByt.length);
////        System.out.println(new String(new String(errByt).getBytes("ISO8859_1"),"UTF-8"));
//        System.out.println(resurt4 == 0 ? "添加文本区域成功" : "添加文本区域失败");
//
//        //*****************第三步 发送节目内容*********************************************************
//
//     	//节目发送
////         retValue = LedControlInf.INSTANCE.LV_SendProgramToDevice(iptobytes);
//
//         retValue = LedControlInf.INSTANCE.LV_SendProgramToDevice(screenNameToBytes,iptobytes,pProgramIdToBytes,pProgramNameToBytes,new byte[0]);
////         if(retValue != 0){
////            retValue = LedControlInf.INSTANCE.LV_GetLastErrInfo(errByt, errByt.length);
////            System.out.println(new String(new String(errByt).getBytes("ISO8859_1"),"UTF-8"));
////         }
//         System.out.println(retValue == 0 ? "节目内容发送成功" : "节目内容发送失败");
//
//         //*****************第四步 发送节目计划,执行播放节目指令 *********************************************************
//         String pDefResVideoFile ="\0";
//
////         MulProgram mulProgram = new MulProgram();
//
//         List<MulProgram> lsMulProgram = new ArrayList<MulProgram>();
//
//         List<ProgramPlan> lsProgramPlan = new ArrayList<ProgramPlan>();
//         ProgramPlan programPlan = new ProgramPlan();
//         programPlan.setCreateDate(String.valueOf(new java.util.Date().getTime()));
//         List<Date> lsDate = new ArrayList<Date>();
//
//         SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
////         Calendar.getInstance().
//         Date date = new Date();
//         date.setDateStart(formatter.parse("2020-03-30").getTime());
//         date.setDateEnd(formatter.parse("2020-04-30").getTime());
//         lsDate.add(date);
//         programPlan.setDate(lsDate);
//         programPlan.setIsDefault(0);
//         List lsPlanWeekDay = new ArrayList();
//         for(int k=0;k<=6;k++){
//
//             lsPlanWeekDay.add(1);
//         }
//
//         programPlan.setPlanWeekDay(lsPlanWeekDay);
//         programPlan.setProgramId(pProgramId);
//         programPlan.setProgramName(pProgramName);
//         programPlan.setProgramType(1);//1标识为轮播节目
//         List<Time> lsTime = new ArrayList<Time>();
//         Time time = new Time();
//         time.setTimeStart("07:59:59");
//         time.setTimeEnd("21:59:59");
//         lsTime.add(time);
//         programPlan.setTime(lsTime);
//         programPlan.setUpdateDate(String.valueOf(new java.util.Date().getTime()));
//         lsProgramPlan.add(programPlan);
//
//         MulProgram mulProgram = new MulProgram();
//         mulProgram.setDefaultPid("");
//         mulProgram.setOnlyCut(0);
//         mulProgram.setProgram(lsProgramPlan);
//
//         lsMulProgram.add(mulProgram);
//
//
////         mulProgram.setProgram(lsProgram);
//
//         //对象转为Json
//         String pPlanJsonData = mapper.writeValueAsString(lsMulProgram);
//         System.out.println(pPlanJsonData);
//         byte[] pPlanDatatobytes = pPlanJsonData.getBytes();
//         retValue = LedControlInf.INSTANCE.LV_SendProgramPlan(iptobytes, pPlanDatatobytes, pDefResVideoFile.getBytes());
//         System.out.println(retValue == 0 ? "节目更新计划发送成功" : "节目更新发送失败");
//
//
//         retValue = LedControlInf.INSTANCE.LV_ProgramSendProcessEnd();
//         System.out.println(retValue == 0 ? "节目缓存清理成功" : "节目缓存清理失败");
//		} catch (JsonGenerationException e) {
//			// TODO Auto-generated catch block
//			e.printStackTrace();
//		} catch (JsonMappingException e) {
//			// TODO Auto-generated catch block
//			e.printStackTrace();
//		} catch (IOException e) {
//			// TODO Auto-generated catch block
//			e.printStackTrace();
//		}
//     }


	//多节目多页面-发送定时节目
	 private static void btMulProgramByPeriod_Click(byte[] iptobytes,int intStepTimeValue) throws ParseException
     {

	   String screenName1 ="test1";
	   String pProgramId = "14";
	   String pProgramName = "14";

	   byte[] pProgramIdToBytes = (pProgramId + "\0") .getBytes();
	   byte[] pProgramNameToBytes = (pProgramName + "\0").getBytes();
	   byte[] screenNameToBytes = (screenName1 + "\0") .getBytes();

	   String rootPath = System.getProperty("user.dir")+"\\resources\\";

	    byte[] errByt =new byte[2048];
	   try {

		 int retValue = 0;
         retValue = LedControlInf.INSTANCE.LV_ClearProgram(screenNameToBytes);
         System.out.println("LV_ClearProgram = " + retValue);

         Random rd = new Random();
         int pageId = rd.nextInt(100);
         //直行
         String src1 = rootPath + "10.bmp";

         //*****************第一步 添加节目页面***********************************************************************
         Page page = new Page();
         page.setPageId(pageId);
         page.setResolution("1920X1080");
         page.setBgColor("#000000");
         page.setBgImg("");
         page.setEqType("Q5");
         page.setPageTime(10);
         UUID uuid = UUID.randomUUID();
         page.setGuid(uuid.toString());

          //对象转为Json
         ObjectMapper mapper = new ObjectMapper();
         String pPageJson = mapper.writeValueAsString(page);
         System.out.println(pPageJson);

         byte[] pageJsontoBytes = (pPageJson+ "\0").getBytes();
         int resurt1 = LedControlInf.INSTANCE.LV_AddPageToProgram(screenNameToBytes, pProgramIdToBytes, pageJsontoBytes);

//         byte[] errByt = new byte[2048];
//         retValue = LedControlInf.INSTANCE.LV_GetLastErrInfo(errByt, errByt.length);
//
//         System.out.println(new String(new String(errByt).getBytes("ISO8859_1"),"UTF-8"));
         System.out.println(resurt1 == 0 ? "添加节目页面成功" : "添加节目页面失败");

         //*****************第二步 在节目页面上添加对应的显示区域*********************************************************

         //图片区域
         PictureArea a = new PictureArea();
         a.setId(1);
         a.setType(1);
         a.setBorderEffect(0);
         a.setBorderSW(0);
         a.setBorderSpeed(0);
         a.setBorderType(0);
         a.setLeft(0);
         a.setTop(0);
         a.setWidth(256);
         a.setHeight(192);
         a.setPauseTime(5);
         a.setRotation(0);
         a.setSiderType(6);
         List<SrcGroup> lsg = new ArrayList<SrcGroup>();
         a.setSrcGroup(lsg);

         SrcGroup s = new SrcGroup();
         s.setId(1);
         s.setSrc(src1);
         a.getSrcGroup().add(s);

         SrcGroup s1 = new SrcGroup();
         s1.setId(2);
         src1 = rootPath + "11.bmp";
         s1.setSrc(src1);
         a.getSrcGroup().add(s1);
         a.setzIndex(0);

         //对象转为Json
         String ajson = mapper.writeValueAsString(a);

         System.out.println(ajson);

         byte[] ajsontobytes = (ajson+ "\0").getBytes();
//         int resurt2 = LedControlInf.INSTANCE.LV_AddArea(iptobytes, pid, ajsontobytes);
         int resurt2 = LedControlInf.INSTANCE.LV_AddArea(screenNameToBytes,pProgramIdToBytes, pageId, ajsontobytes);
//         retValue = LedControlInf.INSTANCE.LV_GetLastErrInfo(errByt, errByt.length);
//         System.out.println(new String(new String(errByt).getBytes("ISO8859_1"),"UTF-8"));
         System.out.println(resurt2 == 0 ? "添加图片区域成功" : "添加图片区域失败");


       //视频区域
         VideoArea videoArea = new VideoArea();
         videoArea.setId(3);
         videoArea.setType(0);
         videoArea.setBorderEffect(1);
         videoArea.setBorderSW(1);
         videoArea.setBorderSpeed(1);
         videoArea.setBorderType(9);
         videoArea.setLeft(0);
         videoArea.setTop(256);
         videoArea.setWidth(288);
         videoArea.setHeight(96);
         videoArea.setPauseTime(5);
         videoArea.setRotation(0);
         videoArea.setSiderType(6);
         List<SrcGroup> lsgVideoArea = new ArrayList<SrcGroup>();
         videoArea.setSrcGroup(lsgVideoArea);

         src1 = rootPath + "21.mp4";
         SrcGroup sVideoArea = new SrcGroup();
         sVideoArea.setId(1);
         sVideoArea.setSrc(src1);
         videoArea.getSrcGroup().add(sVideoArea);

         SrcGroup sVideoArea1 = new SrcGroup();
         sVideoArea1.setId(2);
         src1 = rootPath + "23.mp4";
         sVideoArea1.setSrc(src1);
         videoArea.getSrcGroup().add(sVideoArea1);
         videoArea.setzIndex(0);

         //对象转为Json
         String vjson = mapper.writeValueAsString(videoArea);

         System.out.println(vjson);

         byte[] vjsontobytes = (vjson+ "\0").getBytes();
//         int resurt3 = LedControlInf.INSTANCE.LV_AddArea(iptobytes, pid, vjsontobytes);
         int resurt3 = LedControlInf.INSTANCE.LV_AddArea(screenNameToBytes,pProgramIdToBytes, pageId, vjsontobytes);
//         retValue = LedControlInf.INSTANCE.LV_GetLastErrInfo(errByt, errByt.length);
//         System.out.println(new String(new String(errByt).getBytes("ISO8859_1"),"UTF-8"));
         System.out.println(resurt3 == 0 ? "添加视频区域成功" : "添加视频区域失败");


         //文本区域
         TextArea textArea = new TextArea();
         //id
         textArea.setId(2);
     	//type Int 区域素材类型，字幕对应的类型为:2
         textArea.setType(2);
     	//borderSW Int 区域边框开关 1:开 0:关
         textArea.setBorderSW(0);
      	//borderEffect Int 区域边框特效 0:静止 1:旋转 2:闪烁
         textArea.setBorderEffect(0);
     	//颜色特效 0:无 1:水平渐变 2:垂直渐变 3:斜角渐变
         textArea.setColorEffect(0);
     	//borderSpeed int 区域边框速度 0~4
         textArea.setBorderSpeed(0);
     	//borderType Int 区域边框类型 0~9 详见附录
         textArea.setBorderType(0);
     	//left Int 区域 x 坐标点
         textArea.setLeft(256);
     	//top Int 区域 y 坐标点
         textArea.setTop(0);
     	//width Int 区域宽度
         textArea.setWidth(256);
     	//height Int 区域高度
         textArea.setHeight(64);
     	//background String 背景颜色,如:”#000000”,16 进制的 RRGGBB
         textArea.setBackground("#000000");
     	//fontColor String 文字颜色, 如:”#ffffff”,16 进制的 RRGGBB
         textArea.setFontColor("#00ff00");
     	//fontFamily String 文字字体,如”宋体”
         textArea.setFontFamily("宋体");
     	//fontSize Int 字体大小 12~128 ,单位 px
         textArea.setFontSize(48);
     	//italic Int 是否斜体 1:是 0:否
         textArea.setItalic(0);
     	// bold Int 是否粗体 1:是 0:否
         textArea.setBold(1);
     	//textLine Int 文字线 0:无 1:下划线 2:删除线
         textArea.setTextLine(0);
     	//lineHeight Int 行间距,多行时有效
         textArea.setLineHeight(5);
     	//pauseTime Int 停留时间,当字幕为向左向右平移时的停留时间,连续移 动无效 0~255
         textArea.setPauseTime(5);
     	//scrollSpeed Int 字幕滚动速度 0~14
         textArea.setScrollSpeed(2);
     	//siderType Int 滚动方式 0:静止 1:向左移动 2:向左连续移动 3:向右移动 4:向右连续移动
         textArea.setSiderType(2);
     	//textAlign Int 对齐方式 0:左,1:中间 2:右
         textArea.setTextAlign(0);

         textArea.setTextTop(0);

         String strTextInfo = "AAAA灵信视觉二次开发动态库文本发送";
//         String base64Sign = base64.encodeToString(strTextInfo.getBytes("UTF-8"));
         textArea.setText(strTextInfo);
     	//textShow Int 字幕显示方式 1:单行 0:多行
         textArea.setTextShow(1);
     	//zIndex int 层级
     	textArea.setzIndex(0);

        //对象转为Json
        String tjson = mapper.writeValueAsString(textArea);

        System.out.println(tjson);

        byte[] tjsontobytes = (tjson+ "\0").getBytes();
//        int resurt4 = LedControlInf.INSTANCE.LV_AddArea(iptobytes, pid, tjsontobytes);
        int resurt4 = LedControlInf.INSTANCE.LV_AddArea(screenNameToBytes,pProgramIdToBytes, pageId, tjsontobytes);
//        retValue = LedControlInf.INSTANCE.LV_GetLastErrInfo(errByt, errByt.length);
//        System.out.println(new String(new String(errByt).getBytes("ISO8859_1"),"UTF-8"));
        System.out.println(resurt4 == 0 ? "添加文本区域成功" : "添加文本区域失败");

        //*****************第三步 发送节目内容*********************************************************

     	//节目发送
//         retValue = LedControlInf.INSTANCE.LV_SendProgramToDevice(iptobytes);

         retValue = LedControlInf.INSTANCE.LV_SendProgramToDevice(screenNameToBytes,iptobytes,pProgramIdToBytes,pProgramNameToBytes,new byte[0]);
//         if(retValue != 0){
//            retValue = LedControlInf.INSTANCE.LV_GetLastErrInfo(errByt, errByt.length);
//            System.out.println(new String(new String(errByt).getBytes("ISO8859_1"),"UTF-8"));
//         }
         System.out.println(retValue == 0 ? "节目内容发送成功" : "节目内容发送失败");

         //*****************第四步 发送节目计划,执行播放节目指令 *********************************************************
         String pDefResVideoFile ="\0";

//         MulProgram mulProgram = new MulProgram();


         List<ProgramPlan> lsProgram = new ArrayList<ProgramPlan>();

         ProgramPlan programPlan = new ProgramPlan();
         programPlan.setCreateDate(String.valueOf(new java.util.Date().getTime()));
         programPlan.setProgramId(pProgramId);
         programPlan.setProgramName(pProgramName);
         programPlan.setProgramType(3);//1:轮播节目(该类型节目最多只能1个) 2:插播节目 3:定时节目
         programPlan.setUpdateDate(String.valueOf(new java.util.Date().getTime()));

         List<Date> lsDate = new ArrayList<Date>();
         SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");

         Date date = new Date();
         date.setDateStart(formatter.parse("2020-03-30").getTime());
         date.setDateEnd(formatter.parse("2020-04-30").getTime());
         lsDate.add(date);
         programPlan.setDate(lsDate);

         List<Time> lsTime = new ArrayList<Time>();
         Time time = new Time();
         SimpleDateFormat formatterTime = new SimpleDateFormat("HH:mm:ss");
         time.setTimeStart(formatterTime.format(Calendar.getInstance().getTime()));
         Calendar cal = Calendar.getInstance();
	     cal.setTime(Calendar.getInstance().getTime());
	     cal.add(Calendar.MINUTE, intStepTimeValue);
	     time.setTimeEnd(formatterTime.format(cal.getTime()));

//         time.setTimeStart("15:40:59");
//         time.setTimeEnd("15:59:59");
         lsTime.add(time);
         programPlan.setTime(lsTime);

         programPlan.setIsDefault(0);
         List lsPlanWeekDay = new ArrayList();
         for(int i=0;i<7;i++){
        	 lsPlanWeekDay.add(1);
         }
         programPlan.setPlanWeekDay(lsPlanWeekDay);
         lsProgram.add(programPlan);

//         mulProgram.setProgram(lsProgram);

         //对象转为Json
         String pPlanJsonData = mapper.writeValueAsString(lsProgram);
         System.out.println(pPlanJsonData);
         byte[] pPlanDatatobytes = (pPlanJsonData+ "\0").getBytes();
         retValue = LedControlInf.INSTANCE.LV_SendProgramPlan(iptobytes, pPlanDatatobytes, pDefResVideoFile.getBytes());
         System.out.println(retValue == 0 ? "节目更新计划发送成功" : "节目更新发送失败");


         retValue = LedControlInf.INSTANCE.LV_ProgramSendProcessEnd();
         System.out.println(retValue == 0 ? "节目缓存清理成功" : "节目缓存清理失败");
		} catch (JsonGenerationException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (JsonMappingException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
     }

	//多节目多页面-发送插播节目
	 private static void btMulProgramByInsert_Click(byte[] iptobytes) throws ParseException
     {

	   String screenName1 ="test1";
	   String pProgramId = "15";
	   String pProgramName = "15";

	   byte[] pProgramIdToBytes = (pProgramId + "\0") .getBytes();
	   byte[] pProgramNameToBytes = (pProgramName + "\0").getBytes();
	   byte[] screenNameToBytes = (screenName1 + "\0") .getBytes();

	   String rootPath = System.getProperty("user.dir")+"\\resources\\";

	    byte[] errByt =new byte[2048];
	   try {

		 int retValue = 0;
         retValue = LedControlInf.INSTANCE.LV_ClearProgram(screenNameToBytes);
         System.out.println("LV_ClearProgram = " + retValue);

         Random rd = new Random();
         int pageId = rd.nextInt(100);
         //直行
         String src1 = rootPath + "11.bmp";

         //*****************第一步 添加节目页面***********************************************************************
         Page page = new Page();
         page.setPageId(pageId);
         page.setResolution("1920X1080");
         page.setBgColor("#000000");
         page.setBgImg("");
         page.setEqType("Q5");
         page.setPageTime(10);
         UUID uuid = UUID.randomUUID();
         page.setGuid(uuid.toString());

          //对象转为Json
         ObjectMapper mapper = new ObjectMapper();
         String pPageJson = mapper.writeValueAsString(page);
         System.out.println(pPageJson);

         byte[] pageJsontoBytes = (pPageJson+ "\0").getBytes();
         int resurt1 = LedControlInf.INSTANCE.LV_AddPageToProgram(screenNameToBytes, pProgramIdToBytes, pageJsontoBytes);

//         byte[] errByt = new byte[2048];
//         retValue = LedControlInf.INSTANCE.LV_GetLastErrInfo(errByt, errByt.length);
//
//         System.out.println(new String(new String(errByt).getBytes("ISO8859_1"),"UTF-8"));
         System.out.println(resurt1 == 0 ? "添加节目页面成功" : "添加节目页面失败");

         //*****************第二步 在节目页面上添加对应的显示区域*********************************************************

//         //图片区域
//         PictureArea a = new PictureArea();
//         a.setId(1);
//         a.setType(1);
//         a.setBorderEffect(0);
//         a.setBorderSW(0);
//         a.setBorderSpeed(0);
//         a.setBorderType(0);
//         a.setLeft(0);
//         a.setTop(0);
//         a.setWidth(256);
//         a.setHeight(192);
//         a.setPauseTime(5);
//         a.setRotation(0);
//         a.setSiderType(6);
//         List<SrcGroup> lsg = new ArrayList<SrcGroup>();
//         a.setSrcGroup(lsg);
//
//         SrcGroup s = new SrcGroup();
//         s.setId(1);
//         s.setSrc(src1);
//         a.getSrcGroup().add(s);
//
//         SrcGroup s1 = new SrcGroup();
//         s1.setId(2);
//         src1 = rootPath + "11.bmp";
//         s1.setSrc(src1);
//         a.getSrcGroup().add(s1);
//         a.setzIndex(0);
//
//         //对象转为Json
//         String ajson = mapper.writeValueAsString(a);
//
//         System.out.println(ajson);
//
//         byte[] ajsontobytes = ajson.getBytes();
////         int resurt2 = LedControlInf.INSTANCE.LV_AddArea(iptobytes, pid, ajsontobytes);
//         int resurt2 = LedControlInf.INSTANCE.LV_AddArea(screenNameToBytes,pProgramIdToBytes, pageId, ajsontobytes);
////         retValue = LedControlInf.INSTANCE.LV_GetLastErrInfo(errByt, errByt.length);
////         System.out.println(new String(new String(errByt).getBytes("ISO8859_1"),"UTF-8"));
//         System.out.println(resurt2 == 0 ? "添加图片区域成功" : "添加图片区域失败");


       //视频区域
         VideoArea videoArea = new VideoArea();
         videoArea.setId(3);
         videoArea.setType(0);
         videoArea.setBorderEffect(1);
         videoArea.setBorderSW(1);
         videoArea.setBorderSpeed(1);
         videoArea.setBorderType(9);
         videoArea.setLeft(0);
         videoArea.setTop(64);
         videoArea.setWidth(720);
         videoArea.setHeight(512);
         videoArea.setPauseTime(5);
         videoArea.setRotation(0);
         videoArea.setSiderType(6);
         List<SrcGroup> lsgVideoArea = new ArrayList<SrcGroup>();
         videoArea.setSrcGroup(lsgVideoArea);

         src1 = rootPath + "21.mp4";
         SrcGroup sVideoArea = new SrcGroup();
         sVideoArea.setId(1);
         sVideoArea.setSrc(src1);
         videoArea.getSrcGroup().add(sVideoArea);

         SrcGroup sVideoArea1 = new SrcGroup();
         sVideoArea1.setId(2);
         src1 = rootPath + "23.mp4";
         sVideoArea1.setSrc(src1);
         videoArea.getSrcGroup().add(sVideoArea1);

         SrcGroup sVideoArea2 = new SrcGroup();
         sVideoArea2.setId(3);
         src1 = rootPath + "yxceshi.mp4";
         sVideoArea2.setSrc(src1);
         videoArea.getSrcGroup().add(sVideoArea2);

         videoArea.setzIndex(0);

         //对象转为Json
         String vjson = mapper.writeValueAsString(videoArea);

         System.out.println(vjson);

         byte[] vjsontobytes = (vjson+ "\0").getBytes();
//         int resurt3 = LedControlInf.INSTANCE.LV_AddArea(iptobytes, pid, vjsontobytes);
         int resurt3 = LedControlInf.INSTANCE.LV_AddArea(screenNameToBytes,pProgramIdToBytes, pageId, vjsontobytes);
//         retValue = LedControlInf.INSTANCE.LV_GetLastErrInfo(errByt, errByt.length);
//         System.out.println(new String(new String(errByt).getBytes("ISO8859_1"),"UTF-8"));
         System.out.println(resurt3 == 0 ? "添加视频区域成功" : "添加视频区域失败");


         //文本区域
         TextArea textArea = new TextArea();
         //id
         textArea.setId(2);
     	//type Int 区域素材类型，字幕对应的类型为:2
         textArea.setType(2);
     	//borderSW Int 区域边框开关 1:开 0:关
         textArea.setBorderSW(0);
      	//borderEffect Int 区域边框特效 0:静止 1:旋转 2:闪烁
         textArea.setBorderEffect(0);
     	//颜色特效 0:无 1:水平渐变 2:垂直渐变 3:斜角渐变
         textArea.setColorEffect(0);
     	//borderSpeed int 区域边框速度 0~4
         textArea.setBorderSpeed(0);
     	//borderType Int 区域边框类型 0~9 详见附录
         textArea.setBorderType(0);
     	//left Int 区域 x 坐标点
         textArea.setLeft(0);
     	//top Int 区域 y 坐标点
         textArea.setTop(0);
     	//width Int 区域宽度
         textArea.setWidth(720);
     	//height Int 区域高度
         textArea.setHeight(64);
     	//background String 背景颜色,如:”#000000”,16 进制的 RRGGBB
         textArea.setBackground("#000000");
     	//fontColor String 文字颜色, 如:”#ffffff”,16 进制的 RRGGBB
         textArea.setFontColor("#00ff00");
     	//fontFamily String 文字字体,如”宋体”
         textArea.setFontFamily("宋体");
     	//fontSize Int 字体大小 12~128 ,单位 px
         textArea.setFontSize(48);
     	//italic Int 是否斜体 1:是 0:否
         textArea.setItalic(0);
     	// bold Int 是否粗体 1:是 0:否
         textArea.setBold(1);
     	//textLine Int 文字线 0:无 1:下划线 2:删除线
         textArea.setTextLine(0);
     	//lineHeight Int 行间距,多行时有效
         textArea.setLineHeight(5);
     	//pauseTime Int 停留时间,当字幕为向左向右平移时的停留时间,连续移 动无效 0~255
         textArea.setPauseTime(5);
     	//scrollSpeed Int 字幕滚动速度 0~14
         textArea.setScrollSpeed(2);
     	//siderType Int 滚动方式 0:静止 1:向左移动 2:向左连续移动 3:向右移动 4:向右连续移动
         textArea.setSiderType(2);
     	//textAlign Int 对齐方式 0:左,1:中间 2:右
         textArea.setTextAlign(0);

         textArea.setTextTop(0);

         String strTextInfo = "AAAA灵信视觉二次开发动态库文本发送";
//         String base64Sign = base64.encodeToString(strTextInfo.getBytes("UTF-8"));
         textArea.setText(strTextInfo);
     	//textShow Int 字幕显示方式 1:单行 0:多行
         textArea.setTextShow(1);
     	//zIndex int 层级
     	textArea.setzIndex(0);

        //对象转为Json
        String tjson = mapper.writeValueAsString(textArea);

        System.out.println(tjson);

        byte[] tjsontobytes = (tjson+ "\0").getBytes();
//        int resurt4 = LedControlInf.INSTANCE.LV_AddArea(iptobytes, pid, tjsontobytes);
        int resurt4 = LedControlInf.INSTANCE.LV_AddArea(screenNameToBytes,pProgramIdToBytes, pageId, tjsontobytes);
//        retValue = LedControlInf.INSTANCE.LV_GetLastErrInfo(errByt, errByt.length);
//        System.out.println(new String(new String(errByt).getBytes("ISO8859_1"),"UTF-8"));
        System.out.println(resurt4 == 0 ? "添加文本区域成功" : "添加文本区域失败");

        //*****************第三步 发送节目内容*********************************************************

     	//节目发送
//         retValue = LedControlInf.INSTANCE.LV_SendProgramToDevice(iptobytes);

         retValue = LedControlInf.INSTANCE.LV_SendProgramToDevice(screenNameToBytes,iptobytes,pProgramIdToBytes,pProgramNameToBytes,new byte[0]);
//         if(retValue != 0){
//            retValue = LedControlInf.INSTANCE.LV_GetLastErrInfo(errByt, errByt.length);
//            System.out.println(new String(new String(errByt).getBytes("ISO8859_1"),"UTF-8"));
//         }
         System.out.println(retValue == 0 ? "节目内容发送成功" : "节目内容发送失败");

         //*****************第四步 发送节目计划,执行播放节目指令 *********************************************************
         String pDefResVideoFile ="\0";

          List<ProgramPlan> lsProgram = new ArrayList<ProgramPlan>();

         ProgramPlan programPlan = new ProgramPlan();
         programPlan.setCreateDate(String.valueOf(new java.util.Date().getTime()));
         programPlan.setProgramId(pProgramId);
         programPlan.setProgramName(pProgramName);
         programPlan.setProgramType(2);//1:轮播节目(该类型节目最多只能1个) 2:插播节目 3:定时节目
         programPlan.setUpdateDate(String.valueOf(new java.util.Date().getTime()));

         List<Date> lsDate = new ArrayList<Date>();
         SimpleDateFormat formatterDate = new SimpleDateFormat("yyyy-MM-dd");
         Date date = new Date();
         date.setDateStart(formatterDate.parse("2020-01-01").getTime());
         date.setDateEnd(formatterDate.parse("2022-12-31").getTime());
         lsDate.add(date);
         programPlan.setDate(lsDate);

         List<Time> lsTime = new ArrayList<Time>();

         SimpleDateFormat formatterTime = new SimpleDateFormat("yyyy-MM-dd");
//         Time time = new Time();
//         time.setTimeStart("08:30:00");
//         time.setTimeEnd("11:00:00");
//         lsTime.add(time);
//         Time time1 = new Time();
//         time1.setTimeStart("12:00:00");
//         time1.setTimeEnd("14:00:00");
//         lsTime.add(time1);
//         Time time2 = new Time();
//         time2.setTimeStart("16:00:00");
//         time2.setTimeEnd("17:00:00");
//         lsTime.add(time2);
         Time time3 = new Time();
         time3.setTimeStart("16:30:00");
         time3.setTimeEnd("23:59:59");
         lsTime.add(time3);
         programPlan.setTime(lsTime);

         programPlan.setIsDefault(0);
         List lsPlanWeekDay = new ArrayList();
         for(int i=0;i<7;i++){
        	 lsPlanWeekDay.add(1);
         }
         programPlan.setPlanWeekDay(lsPlanWeekDay);
         lsProgram.add(programPlan);


         //对象转为Json
         String pPlanJsonData = mapper.writeValueAsString(lsProgram);
         System.out.println(pPlanJsonData);
         byte[] pPlanDatatobytes = (pPlanJsonData+ "\0").getBytes();
         retValue = LedControlInf.INSTANCE.LV_SendProgramPlan(iptobytes, pPlanDatatobytes, pDefResVideoFile.getBytes());
         System.out.println(retValue == 0 ? "节目更新计划发送成功" : "节目更新发送失败");


         retValue = LedControlInf.INSTANCE.LV_ProgramSendProcessEnd();
         System.out.println(retValue == 0 ? "节目缓存清理成功" : "节目缓存清理失败");
		} catch (JsonGenerationException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (JsonMappingException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
     }
}
